'''
Copyright(C),2021-2031, Zhenxin Tech. Co., Ltd.

FilePath: sub.py
Author: zhangys
Date: 2021-12-14 00:15:33
LastEditTime: 2021-12-14 00:22:41
LastEditors: zhangys
Description: 订阅者节点
'''
import rclpy
from rclpy.node import Node
from std_msgs.msg import String

class MinimalSub(Node):
    def __init__(self):
        super().__init__('mainimal_sub')
        self.subscription=self.create_subscription(String,'topic',self.listener_callback,10)
    
    def listener_callback(self,msg):
        self.get_logger().info('接收到数据%s'  %msg.data)

def main(args=None):
    rclpy.init(args=args)
    minial_sub=MinimalSub()
    rclpy.spin(minial_sub)

    minial_sub.destroy_node()
    rclpy.shutdown()

if __name__ == '__main__':
    main()